home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX Base Documentation 1998 November
/
IRIX 6.5.2 Base Documentation November 1998.img
/
usr
/
share
/
catman
/
p_man
/
cat3
/
Xm
/
XmSpinBoxValidatePosition.z
/
XmSpinBoxValidatePosition
Wrap
Text File
|
1998-10-30
|
12KB
|
199 lines
XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxxVVVVaaaalllliiiiddddaaaatttteeeePPPPoooossssiiiittttiiiioooonnnn((((3333UUUUXXXXNNNN))))IIIIXXXX SSSSyyyysssstttteeeemmmmXXXXmmmmVVVVSSSSppppiiiinnnnBBBBooooxxxxVVVVaaaalllliiiiddddaaaatttteeeePPPPoooossssiiiittttiiiioooonnnn((((3333XXXX))))
NNNNAAAAMMMMEEEE
XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxxVVVVaaaalllliiiiddddaaaatttteeeePPPPoooossssiiiittttiiiioooonnnn - translate the current value of
the specified XmSpinBox child into a valid position
SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
#include <Xm/SpinBox.h>
iiiinnnntttt XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxxVVVVaaaalllliiiiddddaaaatttteeeePPPPoooossssiiiittttiiiioooonnnn(
WWWWiiiiddddggggeeeetttt tttteeeexxxxttttffffiiiieeeelllldddd,
iiiinnnntttt ****ppppoooossssiiiittttiiiioooonnnn);
VVVVEEEERRRRSSSSIIIIOOOONNNN
This page documents Motif 2.1.
DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
The XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxxVVVVaaaalllliiiiddddaaaatttteeeePPPPoooossssiiiittttiiiioooonnnn function is a utility that can
be used by applications wanting to implement a policy for
tracking user modifications to editable XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxx children
of type _X_m_N_U_M_E_R_I_C. The specifics of when and how the user's
modifications take effect is left up to the application.
_t_e_x_t__f_i_e_l_d
The _t_e_x_t__f_i_e_l_d argument specifies the widget ID of
the child of the XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxx that is being modified.
The requirement on _t_e_x_t__f_i_e_l_dis that it holds the
aaaacccccccceeeessssssssTTTTeeeexxxxttttuuuuaaaallll trait (already a requirement for
children of XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxx). This way, XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxx can
extract the string out of the _t_e_x_t__f_i_e_l_d widget
(even if it is not an _X_m_T_e_x_t_F_i_e_l_d).
_p_o_s_i_t_i_o_n The location pointed to by the position argument
is assigned the result of the translation done by
XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxxVVVVaaaalllliiiiddddaaaatttteeeePPPPoooossssiiiittttiiiioooonnnn.
XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxxVVVVaaaalllliiiiddddaaaatttteeeePPPPoooossssiiiittttiiiioooonnnn first checks to make
sure this is an _X_m_N_U_M_E_R_I_C XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxx child. If it
is not, XXXXSSSSmmmmppppiiiinnnnBBBBooooxxxxVVVVaaaalllliiiiddddaaaatttteeeePPPPoooossssiiiittttiiiioooonnnn sets position to
the current position and returns _X_m_C_U_R_R_E_N_T__V_A_L_U_E.
XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxxVVVVaaaalllliiiiddddaaaatttteeeePPPPoooossssiiiittttiiiioooonnnnattempts to translate the input
string to a floating point number. If this translation
fails, XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxxVVVVaaaalllliiiiddddaaaatttteeeePPPPoooossssiiiittttiiiioooonnnn sets position to the
current position and returns _X_m_C_U_R_R_E_N_T__V_A_L_U_E.
XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxxVVVVaaaalllliiiiddddaaaatttteeeePPPPoooossssiiiittttiiiioooonnnn converts the floating point number
to an integer using the _X_m_N_d_e_c_i_m_a_l_P_o_i_n_t_s resource. Extra
decimal places are truncated. The resulting integer is range
checked to make sure it falls within the valid range defined
by _X_m_N_m_i_n_i_m_u_m_V_a_l_u_e and _X_m_N_m_a_x_i_m_u_m_V_a_l_u_e inclusive. If the
input falls outside this range, XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxxVVVVaaaalllliiiiddddaaaatttteeeePPPPoooossssiiiittttiiiioooonnnn
sets position to the nearest limit and returns either
_X_m_M_I_N_I_M_U_M__V_A_L_U_E or _X_m_M_A_X_I_M_U_M__V_A_L_U_E.
Finally, XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxxVVVVaaaalllliiiiddddaaaatttteeeePPPPoooossssiiiittttiiiioooonnnn checks the integer to
Page 1 (printed 10/24/98)
XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxxVVVVaaaalllliiiiddddaaaatttteeeePPPPoooossssiiiittttiiiioooonnnn((((3333UUUUXXXXNNNN))))IIIIXXXX SSSSyyyysssstttteeeemmmmXXXXmmmmVVVVSSSSppppiiiinnnnBBBBooooxxxxVVVVaaaalllliiiiddddaaaatttteeeePPPPoooossssiiiittttiiiioooonnnn((((3333XXXX))))
make sure it belongs to the series defined by
XXXXmmmmNNNNmmmmiiiinnnniiiimmmmuuuummmmVVVVaaaalllluuuueeee ............ XXXXmmmmNNNNmmmmiiiinnnnuuuummmmuuuummmmVVVVaaaalllluuuueeee ++++ ((((((((nnnn ---- 1111)))) ****
XXXXmmmmNNNNiiiinnnnccccrrrreeeemmmmeeeennnnttttllllVVVVaaaalllluuuueeee)))). If the integer does not belong to this
series, XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxxVVVVaaaalllliiiiddddaaaatttteeeePPPPoooossssiiiittttiiiioooonnnn sets position to the
nearest element which is less than or equal to the integer
and returns _X_m_I_N_C_R_E_M_E_N_T__V_A_L_U_E.
Otherwise, XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxxVVVVaaaalllliiiiddddaaaatttteeeePPPPoooossssiiiittttiiiioooonnnn assigns the integer to
position and returns _X_m_V_A_L_I_D__V_A_L_U_E.
RRRREEEETTTTUUUURRRRNNNN VVVVAAAALLLLUUUUEEEE
The XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxxVVVVaaaalllliiiiddddaaaatttteeeePPPPoooossssiiiittttiiiioooonnnn function returns the status of
the validation. The set of possible values returned is as
follows:
_X_m_C_U_R_R_E_N_T__V_A_L_U_E
Cannot convert, returning current position_value.
_X_m_M_I_N_I_M_U_M__V_A_L_U_E
Less than min.
_X_m_M_A_X_I_M_U_M__V_A_L_U_E
More than max.
_X_m_I_N_C_R_E_M_E_N_T__V_A_L_U_E
Not on increment.
_X_m_V_A_L_I_D__V_A_L_U_E
Okay.
EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
This first example demonstrates how the
XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxxVVVVaaaalllliiiiddddaaaatttteeeePPPPoooossssiiiittttiiiioooonnnnfunction could be used from inside
an XXXXmmmmNNNNmmmmooooddddiiiiffffyyyyVVVVeeeerrrriiiiffffyyyyCCCCaaaallllllllbbbbaaaacccckkkk callback installed on the
XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxx or the XXXXmmmmSSSSiiiimmmmpppplllleeeeSSSSppppiiiinnnnBBBBooooxxxx:
/*
* Install a callback on a spin box arrow press.
*/
XtAddCallback(sb, XmNmodifyVerifyCallback, ModifyVerifyCB, NULL);
XtAddCallback(simple_sb, XmNmodifyVerifyCallback, ModifyVerifyCB, NULL);
with the callback doing:
void ModifyVerifyCB(widget, call_data, client_data) {
XmSpinBoxCallbackStruct *cbs = (XmSpinBoxCallbackStruct*) call_data;
int position;
Widget textual = NULL;
if (XtIsSubclass(w, xmSimpleSpinBoxWidgetClass))
{
Arg args[1];
XtSetArg(args[0], XmNtextField, &textual);
Page 2 (printed 10/24/98)
XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxxVVVVaaaalllliiiiddddaaaatttteeeePPPPoooossssiiiittttiiiioooonnnn((((3333UUUUXXXXNNNN))))IIIIXXXX SSSSyyyysssstttteeeemmmmXXXXmmmmVVVVSSSSppppiiiinnnnBBBBooooxxxxVVVVaaaalllliiiiddddaaaatttteeeePPPPoooossssiiiittttiiiioooonnnn((((3333XXXX))))
XtGetValues(w, args, 1);
}
else if (XtIsSubclass(w, xmSpinBoxWidgetClass))
textual = cbs->widget;
else
textual = (Widget) NULL;
...
if (XmSpinBoxValidatePosition(textual, &position) == XmCURRENT_VALUE)
XBell(XtDisplay(w), 0);
else
cbs->position = position;
}
This second example demonstrates how the
XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxxVVVVaaaalllliiiiddddaaaatttteeeePPPPoooossssiiiittttiiiioooonnnnfunction could be used from inside
an XXXXmmmmNNNNaaaaccccttttiiiivvvvaaaatttteeeeCCCCaaaallllllllbbbbaaaacccckkkk callback installed on the TTTTeeeexxxxttttFFFFiiiieeeelllldddd
child of the XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxx:
/*
* Install a callback on a spin box arrow press.
*/
XtAddCallback(tf, XmNactivateCallback, ModifyVerifyChildCB, NULL);
with the callback doing:
void ModifyVerifyChildCB(widget, call_data, client_data) {
int position;
Widget textual = widget;
Arg args[1];
if (XmSpinBoxValidatePosition (textual, &position) == XmCURRENT_VALUE)
XBell(XtDisplay(widget), 0);
/* Set the position constraint resource of the textfield */
XtSetArg(args[0], XmNposition, position);
XtSetValues(textual, args, 1);
}
SSSSEEEEEEEE AAAALLLLSSSSOOOO
XXXXmmmmSSSSppppiiiinnnnBBBBooooxxxx(3), XXXXmmmmCCCCrrrreeeeaaaatttteeeeSSSSppppiiiinnnnBBBBooooxxxx(3)
Page 3 (printed 10/24/98)